/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package recursivemethods;

/**
 *
 * @author NIRAJ
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
     //  String output = reverseString("niraj");

int value = sumDigits(12689);
System.out.println("--" + value);
       // int val = findFact(6);
        //System.out.println("Output: " +output  + " Value: " + val );
int c=0;
        for(int i=1; i<=11; i++){
          
         //   System.out.print(fibonacci(c++) + ",");
        }
    }

    private static String reverseString(String str) {
        if(str.length() <= 1)
        {
            return str;
        }
        System.out.println(str);
        return  reverseString(str.substring(1)) + str.charAt(0);
               

    }

    private static int findFact(int n){
        //n * (n-1)
        //3 * 2 * 1
        if(n <= 1){
            return 1;
        }
       
        return findFact(n-1) * n;
    }

    private static int fibonacci(int n){
        //0, 1, 1, 2, 3, 5, 8, 13, 21, 34...
        //0, 1, 1, 2, 3,

        if(n <= 1)
            return n;
        else
            return (fibonacci(n-1) + fibonacci(n-2));

    }

    private static int sumDigits(int n){
        //n = 125 >> Ans: 1+2+5 = 8
        String str = String.valueOf(n);
        if(str.length() <= 1)
        {
            return Integer.parseInt(str);}

        return Integer.parseInt(String.valueOf(str.charAt(0))) + sumDigits(Integer.parseInt(str.substring(1)));

       
    }

}
